package org.vacoor.nothing.misc.express.usps.api.address;

import org.vacoor.nothing.misc.express.usps.api.UspsRequest;
import org.vacoor.nothing.misc.express.usps.api.data.UspsZipCode;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * 城市/州查找
 * <p/>
 * City/State Lookup Web Tool
 * https://www.usps.com/business/web-tools-apis/address-information-api.htm#_Toc365013019
 * <p/>
 * 请求:
 * API: CityStateLookup
 * XML:
 * <pre>
 * <code>
 * <CityStateLookupRequest USERID="xxxxxxx">
 *   <ZipCode ID= "0"><Zip5>20770</Zip5></ZipCode>
 *   <ZipCode ID= "0"><Zip5>20770</Zip5></ZipCode>
 * </CityStateLookupRequest>
 * </code>
 * </pre>
 * 响应:
 * <pre>
 * <code>
 * <CityStateLookupResponse>
 *   <ZipCode ID="0">
 *      <Zip5>90210</Zip5>
 *      <City>BEVERLY HILLS</City>
 *      <State>CA</State>
 *   </ZipCode>
 * </CityStateLookupResponse>
 * </code>
 * </pre>
 *
 * @author vacoor
 */
@XmlRootElement(name = "CityStateLookupRequest")
public class CSLRequest extends UspsRequest {
    public static final String API = "CityStateLookup";

    @XmlElement(name = "ZipCode")
    private List<UspsZipCode> zipCodes;

    public CSLRequest() {
        super(NO_REVISION);
        this.zipCodes = new ArrayList<UspsZipCode>();
    }

    public CSLRequest add(UspsZipCode... zipCodes) {
        Collections.addAll(this.zipCodes, zipCodes);
        return this;
    }
}
